<template>
  <div class="person">
    <h2 ref="title">姓名：{{ name }}</h2>
    <h2>年龄：{{ age }}</h2>
    <button @click="showQiang">打印强哥所在的元素</button>
  </div>
</template>

<script>
  export default {
    name:'Person',
    data() {
      return {
        name:'强哥',
        age:18
      }
    },
    methods: {
      showQiang(){
        console.log(this.$refs.title)
      }
    },
  }
</script>

<style scoped>
  .person {
    margin-top: 10px;
    background-color: skyblue;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 10px;
  }
</style>